<!DOCTYPE HTML>
<html>
<head>
  {include file="common@base/head"/}
    {block name="style"}
    <style>
    body {background: url(__STATIC__/base/images/bg.png) repeat #6b6b6b;}
    .layui-form-switch {height: 24px;padding: 0px 15px;margin: 0 auto;}</style>
    {/block}

</head>
<body id="login-admin">

  <!-- 主体 -->
    <div id="main-container" class="container" style="position:relative">
        <div class="no_side_main_body">
              <div class="top_content">
                  <div class="log_wrap">
                      <section class="login_box">
                  {php} if(config('app.IS_QRCODE_LOGIN')){ {/php}
                        <div class=login_code style="text-align: center;">
                            <p style="color: #0a8cd2">微信扫码登录</p>
                            <img style='width:200px;height:200px;margin:20px 0;' alt="扫码登录" src="{$qrcode}"><br>
                            <a href='javascript:;' onclick='one_login()'>帐号密码登录</a>
                          </div>
                  {php} } {/php}
                          <form class="login-form layui-form" action="{:U('login',['wpid'=>0])}" method="post" style="display:{php}if(config('app.IS_QRCODE_LOGIN')) echo 'none';{/php} ">
                                  <div class="form_body" id="input_login" >
                                        <h6>欢迎使用{:config('app.WEB_SITE_TITLE')}</h6>
                                        <div class="input_panel">
                                          <div class="control-group">
                                              <label class="control-label" for="inputEmail">用户名</label>
                                            <div class="controls">
                                                <i class="fa fa-user"></i>
                                              <input type="text" id="inputEmail" class="span3" placeholder="请输入用户名"  ajaxurl="/user/checkUserNameUnique.html" errormsg="请填写1-16位用户名" nullmsg="请填写用户名" datatype="*1-16" value="" name="username">
                                            </div>
                                          </div>
                                          <div class="control-group">
                                              <label class="control-label" for="inputPassword">密码</label>

                                            <div class="controls">
                                                <i class="fa fa-key"></i>
                                              <input type="password" id="inputPassword"  class="span3" placeholder="请输入密码"  errormsg="密码为6-20位" nullmsg="请填写密码" datatype="*6-20" name="password">
                                            </div>
                                          </div>

                                          {php}if(config('app.WEB_SITE_VERIFY')) { {/php}
                                          <div class="control-group">
                                            <label class="control-label" for="verify">验证码</label>
                                            <div class="controls">
                                               <span class="fa fa-keyboard-o"></span>
                                              <input type="text" autocomplete="off" id="verify" class="span3" placeholder="请输入验证码"  errormsg="请填写5位验证码" nullmsg="请填写验证码" datatype="*5-5" name="verify">
                                              <a href="javascript:;" class="reloadverify_a" style="right:-12px;">换一张?</a>
                                            </div>
                                          </div>
                                          {php} } {/php}
                                       </div>
                                      {php}if(config('app.WEB_SITE_VERIFY')) { {/php}
                                      <div class="control-group">
                                        <label class="control-label"></label>
                                        <div class="controls" style="margin-top:10px">
                                            <img class="verifyimg reloadverify" alt="点击切换" src="{:captcha_src()}" style="width:300px;cursor:pointer;">
                                        </div>
                                      </div>
                                      {php} } {/php}
                                      <div class="control-group">
                                          <label class="control-label"></label>
                                          <div class="controls">
<!--                                              <input type="checkbox" name="remember" lay-skin="switch" lay-text="下次自动登录|不要自动登录" />-->
                                              {php} if(config('app.IS_QRCODE_LOGIN')){ {/php}
                                              <a href='javascript:;' onclick='code_login()' style="position:absolute;top:2px;margin-left:100px;">扫码登录</a>
                                              {php} } {/php}
                                          </div>
                                      </div>
                                      <div class="control-group">
                                        <div class="controls">
                                          <button type="submit" class="btn btn-large">登 录</button>
                                         </div>
                                          <div class="controls Validform_checktip text-warning"></div>

                                          {php}if(config('app.USER_ALLOW_REGISTER')) { {/php}
                                          <div class="controls" style="color: #999; text-align: center;">
                                              还没账号? <a style="width:266px;>" href="{:U('User/register')}">立 即 注 册</a>
                                          </div>
                                          {php} } {/php}
                                      </div>
                                  </div>
                               </form>

                        </section>
                    </div>
                </div>
        </div>
    </div>

  <!-- /主体 -->

  <!-- 底部 -->
  {include file="common@base/footer"/}

    
    {block name="script"}
        <script type="text/javascript">
            layui.use('form', function(){
                var form = layui.form;
            });
          var check_even;
          function check_login(){
            check_even = setInterval(function(){
              $.post(
                '{:U("login")}',{},
                function(res){
                    if(res.code==0){
                        window.location.href = res.url;
                    }else if(res.status==2){
                        clearTimeout(check_even);
                        $('.login_bind').show();
                        $('.login_ewm').hide();
                        $('#login_uid').val(res.login_uid);
                    }

                }
              );
            },3000);
          }
          {php} if(config('app.IS_QRCODE_LOGIN')){ {/php}
          check_login();
          {php} } {/php}
          function code_login(){
            check_login();
            $('.login-form').hide();
            $('.login_code').show();
          }
          function one_login(){
            clearInterval(check_even);
            $('.login_code').hide();
            $('.login-form').show();
          }
            $(document)
              .ajaxStart(function(){
                $("button:submit").addClass("log-in").attr("disabled", true);
              })
              .ajaxStop(function(){
                $("button:submit").removeClass("log-in").attr("disabled", false);
              });


            $("form").submit(function(){
              var self = $(this);
              $.post(self.attr("action"), self.serialize(), success, "json");
              return false;

              function success(data){
                if(data.code==0){
                  window.location.href = data.url;
                } else {
                  self.find(".Validform_checktip").text(data.msg);
                  //刷新验证码
                  $(".reloadverify").click();
                }
              }
            });

          $(function(){
            var verifyimg = $(".verifyimg").attr("src");
                  $(".reloadverify,.reloadverify_a").click(function(){
                      if( verifyimg.indexOf('?')>0){
                          $(".verifyimg").attr("src", verifyimg+'&random='+Math.random());
                      }else{
                          $(".verifyimg").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
                      }
                  });
            $('input').focus(function(){
              $(this).parent().find('.fa').css('color','#44b549');
              })
            $('input').blur(function(){
              $(this).parent().find('.fa').css('color','#aaa');
              })
          });
                //登陆判断父页面是否跳转到登录页
                if (window.top!=null && window.top.document.URL!=document.URL){
                    window.top.location= document.URL;
                }
        </script>
    {/block} <!-- 用于加载js代码 -->
    <div class="hidden"><!-- 用于加载统计代码等隐藏元素 -->
        {block name="hidden"}{/block}
    </div>    
  <!-- /底部 -->
</body>
</html>

